// @vitest-environment jsdom // // The [locale] mirror pages re-export the bare page and add getStaticPaths, // which tells `voltro build` which locale-prefixed paths to emit. The default // locale (en) is NOT listed — it lives at the bare path — so only /de is // produced. The dynamic release mirror emits the CROSS-PRODUCT of non-default // locales × release slugs (here: de × every release). import { describe, expect, test, vi } from 'vitest' interface Release { version: string releasedAt: string slug: string tags: ReadonlyArray title: string summary: string html: string } const releases: ReadonlyArray = [ { version: '0.2.0', releasedAt: '2026-06-21', slug: 'v0-2-0', tags: ['feature'], title: 'Typed env', summary: 'Declare your environment once.', html: '

body

', }, { version: '0.1.0', releasedAt: '2026-01-15', slug: 'v0-1-0', tags: ['feature'], title: 'First release', summary: 'The initial cut.', html: '

body

', }, ] // The real release source reads .mdx via `import.meta.glob` + node-gated shiki; // mock it (used by the [slug] mirror's cross-product getStaticPaths and by the // transitively-imported base pages). const releaseBySlug = (slug: string): Release | undefined => releases.find((r) => r.slug === slug) vi.mock('../../lib/releases', () => ({ releases, releaseBySlug })) vi.mock('@voltro/changelog', () => ({ highlightRelease: async (r: Release) => r, })) vi.mock('@voltro/web', () => ({ useLoaderData: () => ({ release: releases[0] }), notFound: (detail?: string) => { throw new Error(detail) }, useLocation: () => '/', })) vi.mock('@voltro/i18n', () => ({ defineCatalog: (c: T): T => c, defineLocale: () => (c: T): T => c, useLocale: () => 'en', useT: (id: string) => id, T: ({ id }: { id: string }) => id, })) const indexMirror = await import('./page') const releaseMirror = await import('./[slug]/page') describe('index mirror — getStaticPaths', () => { test('emits only non-default locales (just /de)', async () => { const paths = await indexMirror.getStaticPaths() expect(paths).toEqual([{ params: { locale: 'de' } }]) }) test('re-exports the base page component + its meta function', () => { expect(typeof indexMirror.default).toBe('function') expect(indexMirror.meta({ locale: 'de' }).title).toContain('Changelog') }) }) describe('release mirror — getStaticPaths (locale × slug cross-product)', () => { test('emits one path per non-default locale × release slug', async () => { const paths = await releaseMirror.getStaticPaths() expect(paths).toEqual(releases.map((r) => ({ params: { locale: 'de', slug: r.slug } }))) }) test('re-exports the base release page + its config exports', () => { expect(typeof releaseMirror.default).toBe('function') expect(releaseMirror.renderMode).toBe('static') expect(releaseMirror.interactive).toBe('none') expect(typeof releaseMirror.loader).toBe('function') }) })